﻿using System;
using System.Collections;
using System.Configuration;
using System.Web.Configuration;
using HospitalSystem.Core;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;

namespace HospitalSystem
{
    public partial class rechealthpromotion : System.Web.UI.Page
    {

        private servicerecordLog _SA;
        string svccode = WebConfigurationManager.AppSettings["svccode2"];
   
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["id"] == null)
            {

                MessageBox2("กรุณากดค้นหา หรือลงทะเบียนการคัดกรองเด็กก่อน", "checkcid2.aspx");

            }

            else
            {
                _SA = new servicerecordLog();
                if (!IsPostBack)
                {

                    String CaseNo = (string)Session["CaseNo"];
                    psnumber.Text = (string)Session["id"];
                    String cid = psnumber.Text;
                    _SA.BindData(GridView1, svccode, cid, CaseNo);

                    String ShowValue = (string)Session["id"];
                    psnumber.Text = ShowValue;
                    _SA.readtodatatable(psnumber, GridView1, GridView11, svccode);
                
                }

            }

        }

        private void MessageBox2(string msg, string urld)
        {
            Label lbl = new Label();
            lbl.Text = "<script language='javascript'>" + Environment.NewLine + "window.alert('" + msg + "');" + "window.location.href='" + urld + "';" + "</script>";
            Page.Controls.Add(lbl);
        }
       
        protected void Button1_Click(object sender, EventArgs e)
        {
            String cid = psnumber.Text;
            String CaseNo = (string)Session["CaseNo"]; ;
            _SA.procesbutton(SelectStat, GridView1, psnumber, GridView11, svccode, cid, CaseNo);
        }

        //protected void findstaffID()
        //{



        //    string constr = WebConfigurationManager.ConnectionStrings["strconnection"].ConnectionString;
        //    SqlConnection conn = new SqlConnection(constr);

        //    SqlCommand CmdSql2 = new SqlCommand("SELECT Staff_id FROM [Employee] where Username=@Username", conn);
        //    conn.Open();
        //    CmdSql2.Parameters.AddWithValue("@Username", Session["idlogin"]);

        //    SqlDataReader reader2 = CmdSql2.ExecuteReader();



        //    if (reader2.Read())
        //    {
        //        Label3.Text = reader2["Staff_id"].ToString();


        //    }
        //    else
        //    {

        //    }
        //    conn.Close();
        //    reader2.Close();

        //}


    }
}